package com.pds.web.monitor.controller;

import com.pds.common.annotation.Log;
import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.common.enums.BusinessType;
import com.pds.web.monitor.domain.PdsMonitorTaskActivity;
import com.pds.web.monitor.service.IPdsMonitorTaskActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/monitorTaskActivity")
public class PdsMonitorTaskActivityController extends BaseController {

    @Autowired
    private IPdsMonitorTaskActivityService pdsMonitorTaskActivityService;

    /**
     * 新增
     *
     * @param pdsMonitorTaskActivity
     * @return
     */
//    @Log(title = "监测任务新增活动", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public R<PdsMonitorTaskActivity> addActivity(@RequestBody PdsMonitorTaskActivity pdsMonitorTaskActivity) {
        return R.ok(pdsMonitorTaskActivityService.addActivity(pdsMonitorTaskActivity));
    }

    /**
     * 删除 -- 根据id
     *
     * @param id
     * @return
     */
//    @Log(title = "监测任务删除活动", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public R<Boolean> deleteActivity(@RequestParam Long id) {
        return R.ok(pdsMonitorTaskActivityService.deleteActivity(id));
    }

    /**
     * 更新
     *
     * @param pdsMonitorTaskActivity
     * @return
     */
//    @Log(title = "监测任务更新活动", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public R<Boolean> updateActivity(@RequestBody PdsMonitorTaskActivity pdsMonitorTaskActivity) {
        return R.ok(pdsMonitorTaskActivityService.updateActivity(pdsMonitorTaskActivity));
    }

    /**
     * 查询 -- 分页/条件：taskId，activityName，activityDate
     *
     * @param pdsMonitorTaskActivity
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo listPlaceActivity(PdsMonitorTaskActivity pdsMonitorTaskActivity) {
        startPage();
        List<PdsMonitorTaskActivity> list = pdsMonitorTaskActivityService.selectActivityList(pdsMonitorTaskActivity);

        return getDataTable(list);
    }
}
